﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using QuanLyVanBanBUS;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;

public partial class QLVB_User_BaoCaoDanhSachPhieuTrinh : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //
        rptDanhSachPhieuTrinh rpt = new rptDanhSachPhieuTrinh();

        DataTable dt = new DataTable();
        dt.Columns.Add("SoVanBan");
        dt.Columns.Add("TenVanBan");
        dt.Columns.Add("NgayHetHieuLuc");
        dt.Columns.Add("TenDonViSoanThao");

        PhieuTrinh ptDTO = new PhieuTrinh();
        ptDTO.MaPhieuTrinh = (Int32)Session["MaPhieuTrinh"];
        
        PhieuTrinhBUS ptBUS = new PhieuTrinhBUS();
        IList<PhieuTrinh> lstPhieuTrinh = ptBUS.rptDanhSachPhieuTrinh(ptDTO);
        foreach (PhieuTrinh pt in lstPhieuTrinh)
        {
            DataRow dr;
            dr = dt.NewRow();
            dr["SoVanBan"] = pt.SoVanBan;
            dr["TenVanBan"] = pt.TenVanBan;
            dr["NgayHetHieuLuc"] = pt.NgayHetHieuLuc;
            dr["TenDonViSoanThao"] = pt.TenDonViSoanThao;
            dt.Rows.Add(dr);
        }

        rpt.SetDataSource(dt);

        rvDanhSachPhieuTrinh.ReportSource = rpt;

        //
        TextObject txtSoThuTu = (TextObject)rpt.ReportDefinition.Sections["Section1"].ReportObjects["Text34"];
        txtSoThuTu.Text = (String)Session["SoThuTu"];
        if (txtSoThuTu.Text.Length > 4)
        {
            txtSoThuTu.Text = txtSoThuTu.Text.Substring(0, 4);
        }

        TextObject txtNgay = (TextObject)rpt.ReportDefinition.Sections["Section1"].ReportObjects["Text15"];
        txtNgay.Text = DateTime.Now.Date.Day.ToString();
        TextObject txtThang = (TextObject)rpt.ReportDefinition.Sections["Section1"].ReportObjects["Text17"];
        txtThang.Text = DateTime.Now.Date.Month.ToString();
        TextObject txtNam = (TextObject)rpt.ReportDefinition.Sections["Section1"].ReportObjects["Text19"];
        txtNam.Text = DateTime.Now.Date.Year.ToString();
    }
}